<?php

/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 * http://www.gnu.org/copyleft/gpl.html
 */
 


/**
 *  @file
 *  @Author Samuel Maura
 *  Presentation management
 */


class Html{


function pageHeaderStart($title){

$out =<<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>$title</title>
EOF;
echo $out;
}


function addJs($path){
  $out='';
  if (!empty($path) && is_array($path)){
    foreach($path as $item){
      $out .= "<script type='text/javascript' src='{$item}'></script>";
    }  
  }
  echo $out;
}

function pageHeaderEnd(){
  $out=<<<EOF
</head>
EOF;

echo $out;
}

function pageBodyStart(){

$out =<<<EOF
<body>
<div id="page">
EOF;
echo $out;
}


function displayLabel($label){
  $out=<<<EOF
<div class="page_label"><span>$label</span></div>
EOF;
echo $out;
}

function displayLoginMenu($username){
if (isset($username)){
 $out=<<<EOF
<div class="login_menu">
  <ul>
    <li><span class='username'>$username</span></li>
    <li><a href='../views/wikiusersettings.php'>Settings</a></li>
    <li><a href='../controllers/wikilogout.php'>Logout</a></li>
  </ul>
</div>
EOF;
}
else{
  $out=<<<EOF
<div class="login_menu">
  <ul>
    <li><a href='../views/wikilogin.php'>Login</a></li>
  </ul>
</div>
EOF;
}
echo $out;
}


function displayWikiMenu(){
 $out=<<<EOF
<div class="wiki_menu">
  <ul>
    <li><a href='../views/wikicreate.php'>New Page</a></li>
    <li><a href='../views/wikidashboard.php'>All Pages</a></li>
  </ul>
</div>
EOF;
echo $out;
}

function displayWikiMenuDetails($id,$title,$version){
 $out=<<<EOF
<div class="wiki_menu">
  <ul>
    <li><a href='../views/wikidashboard.php'>All Pages</a></li>
    <li><a href='../views/wikicreate.php?action=edit&page_id=$id&version=$version'>Edit this page</a></li>
    <li><a href='../controllers/deletepage.php?action=delete&page_id=$id&version=$version'>Delete this page</a></li>
    <li><a href='../views/wikipage.php?action=history&title=$title&page_id=$id&version=$version'>History</a></li> 
  </ul>
</div>
EOF;
echo $out;
}


function displaySubMenu(){

}

function displayErrorBlock($msg){
  $out=<<<EOF
<div class="page_error_block">$msg</div>
EOF;
echo $out;
}


function mainStyle(){
  $out=<<<EOF
<link rel="stylesheet" type="text/css" media="all" href="../css/main.css">
EOF;
  echo $out;
}


function style($type){
 $out = null;
 
 switch($type){
   case 'login':
     $out='<link rel="stylesheet" type="text/css" media="all" href="../css/login.css">';
    break;
    case 'registration':
      $out='<link rel="stylesheet" type="text/css" media="all" href="../css/registration.css">';
    break;
    case 'error':
      $out='<link rel="stylesheet" type="text/css" media="all" href="../css/error.css">';
    break;
 }    
  echo $out;
  
}


function pageBodyEnd(){
 $out =<<<EOF
</div>
</body>
</html>
EOF;
echo $out;
}

function pageFooter(){
$out =<<<EOF
<div class="wiki_footer">
  <ul>
    <li><a href="../views/privacy">Privacy</a></li>
    <li><a href="../views/terms">Terms and Conditions</a></li>
    <li><a href="../views/about">About Us</a></li> 
  </ul>
</div>
EOF;
echo $out;
}



}

?>


